package com.care.doctor.remote.factory;

import com.care.common.core.domain.Result;
import com.care.doctor.common.domain.DTODepartment;
import com.care.doctor.common.req.ListReq;
import com.care.doctor.remote.DepartmentRemoteService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author: 靳家振
 * @Date: 2024/3/23 20:38
 * @Description:
 **/

@Component
public class RemoteDepartmentFallbackFactory implements FallbackFactory<DepartmentRemoteService> {
    public static final Logger log = LoggerFactory.getLogger (RemoteDepartmentFallbackFactory.class);
    @Override
    public DepartmentRemoteService create(Throwable cause) {
        log.error ("调用部门服务失败：{}", cause.getMessage ());
        return new DepartmentRemoteService () {
            @Override
            public Result<PageInfo<DTODepartment>> findDepartment(ListReq req) {
                return Result.error ("科室列表服务错误，请稍后再试");
            }

            @Override
            public Result listAll() {
                return null;
            }
        };
    }
}
